<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TagM: pRTOS.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">TagM
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">pRTOS.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//**************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">// This file contains its own documentation in Doxygen format.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">// After running doxygen: open the rtf file; select all; r-click-&gt;update.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;<span class="preprocessor">#ifndef __RTOS</span></div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define __RTOS</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="preprocessor">#define RTOS_VERSION &quot;V3.02 (2011-05-24)&quot;</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="comment">// we need NULL</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="preprocessor">#include &lt;cstring&gt;</span></div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;<span class="preprocessor">#define global_logging 1</span></div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;<span class="preprocessor">#define RTOS_STATISTICS_ENABLED 1</span></div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> RTOS_DEFAULT_STACK_SIZE = 2048;</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> RTOS_MAX_PRIORITY = 10000;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;   <span class="comment">// The macro HERE transates to a newline, the file-name, &quot;:&quot;, and</span></div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;   <span class="comment">// the line-number of the place where the HERE macro appears.</span></div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;   <span class="comment">// This can be used for debug logging. used by the trace macro.</span></div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;<span class="preprocessor">#define HERE_STR( X ) #X</span></div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define HERE2( F, L ) ( &quot;\n&quot; F &quot;:&quot; HERE_STR( L ))</span></div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define HERE HERE2( __FILE__, __LINE__ )</span></div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;   <span class="comment">// Printing to trace (instead of cout) prepends HERE and a space,</span></div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;   <span class="comment">// or trace can be used standalone like &#39;trace;&#39;</span></div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;<span class="preprocessor">#define trace ( std::cout &lt;&lt; HERE &lt;&lt; &quot; &quot; )</span></div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;   <span class="comment">// allocate memory for the string and copy the content</span></div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;<span class="keyword">const</span> <span class="keywordtype">char</span> * string_allocate( <span class="keyword">const</span> <span class="keywordtype">char</span> *name );</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;<span class="comment">// the macro RTOS_STATISTICS is used to prefix a single line</span></div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;<span class="comment">// that will be commented out when statistics is disabled</span></div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;<span class="preprocessor">#if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;<span class="preprocessor"></span><span class="preprocessor">   #define RTOS_STATISTICS( x ) x</span></div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#else</span></div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;<span class="preprocessor"></span><span class="preprocessor">   #define RTOS_STATISTICS( x )</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;<span class="keyword">const</span> <span class="keywordtype">char</span> * string_allocate( <span class="keyword">const</span> <span class="keywordtype">char</span> *name );</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;<span class="preprocessor">#define  S * ( 1000 * 1000 )</span></div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define MS * 1000</span></div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;<span class="preprocessor"></span><span class="preprocessor">#define US * 1</span></div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;</div>
<div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;</div>
<div class="line"><a name="l00283"></a><span class="lineno">  283</span>&#160;</div>
<div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;<span class="comment">// class RTOS</span></div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;<span class="comment">//</span></div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160;<span class="comment"></span><span class="comment">//</span></div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;<span class="comment">//***************************************************************************</span></div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;</div>
<div class="line"><a name="l00296"></a><span class="lineno"><a class="code" href="class_r_t_o_s.html">  296</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a> {</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">task</a>;</div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a>;</div>
<div class="line"><a name="l00300"></a><span class="lineno">  300</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a>;</div>
<div class="line"><a name="l00301"></a><span class="lineno">  301</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a>;</div>
<div class="line"><a name="l00302"></a><span class="lineno">  302</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a>;</div>
<div class="line"><a name="l00303"></a><span class="lineno">  303</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">clock</a>;</div>
<div class="line"><a name="l00304"></a><span class="lineno">  304</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">mutex</a>;</div>
<div class="line"><a name="l00305"></a><span class="lineno">  305</span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mailbox.html" title="synchronous handling over of a data item">mailbox</a>;</div>
<div class="line"><a name="l00306"></a><span class="lineno">  306</span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T, const <span class="keywordtype">int</span> SIZE&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1channel.html" title="waitable data queue">channel</a>;</div>
<div class="line"><a name="l00307"></a><span class="lineno">  307</span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1pool.html" title="place to store and rectrieve data, no built-in synchronisation">pool</a>;</div>
<div class="line"><a name="l00308"></a><span class="lineno">  308</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a>;</div>
<div class="line"><a name="l00309"></a><span class="lineno">  309</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a>;</div>
<div class="line"><a name="l00310"></a><span class="lineno">  310</span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a>;</div>
<div class="line"><a name="l00311"></a><span class="lineno">  311</span>&#160;</div>
<div class="line"><a name="l00312"></a><span class="lineno">  312</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00313"></a><span class="lineno">  313</span>&#160;   <span class="keyword">class </span>waitable_set;</div>
<div class="line"><a name="l00314"></a><span class="lineno">  314</span>&#160;   <span class="keyword">class </span>callback;</div>
<div class="line"><a name="l00315"></a><span class="lineno">  315</span>&#160;</div>
<div class="line"><a name="l00317"></a><span class="lineno">  317</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">task</a> * rtos_current_task;</div>
<div class="line"><a name="l00318"></a><span class="lineno">  318</span>&#160;</div>
<div class="line"><a name="l00320"></a><span class="lineno">  320</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">bool</span> must_clear;</div>
<div class="line"><a name="l00321"></a><span class="lineno">  321</span>&#160;   </div>
<div class="line"><a name="l00323"></a><span class="lineno">  323</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> do_statistics_clear (<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00324"></a><span class="lineno">  324</span>&#160;</div>
<div class="line"><a name="l00326"></a><span class="lineno">  326</span>&#160;   <a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>( <span class="keywordtype">void</span> ){}</div>
<div class="line"><a name="l00327"></a><span class="lineno">  327</span>&#160;</div>
<div class="line"><a name="l00329"></a><span class="lineno">  329</span>&#160;   <span class="keyword">static</span> callback * timerList;</div>
<div class="line"><a name="l00330"></a><span class="lineno">  330</span>&#160;   </div>
<div class="line"><a name="l00332"></a><span class="lineno">  332</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( callback * t );</div>
<div class="line"><a name="l00333"></a><span class="lineno">  333</span>&#160;</div>
<div class="line"><a name="l00335"></a><span class="lineno">  335</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">task</a> * taskList;</div>
<div class="line"><a name="l00336"></a><span class="lineno">  336</span>&#160;   </div>
<div class="line"><a name="l00338"></a><span class="lineno">  338</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">task</a> * <a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">task</a> );</div>
<div class="line"><a name="l00339"></a><span class="lineno">  339</span>&#160;</div>
<div class="line"><a name="l00341"></a><span class="lineno">  341</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">bool</span> scheduler_running;</div>
<div class="line"><a name="l00342"></a><span class="lineno">  342</span>&#160;</div>
<div class="line"><a name="l00344"></a><span class="lineno">  344</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> beat (<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00345"></a><span class="lineno">  345</span>&#160;</div>
<div class="line"><a name="l00347"></a><span class="lineno">  347</span>&#160;   <span class="keyword">friend</span> <span class="keywordtype">void</span>  <a class="code" href="class_r_t_o_s.html#a652c85c18e3a82a8fdd9ccd5bc1abd47" title="the timer interrupt, updates runTime and ElapsedTime">timerISR</a> (<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l00348"></a><span class="lineno">  348</span>&#160;</div>
<div class="line"><a name="l00349"></a><span class="lineno">  349</span>&#160;<span class="preprocessor">#if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l00350"></a><span class="lineno">  350</span>&#160;<span class="preprocessor"></span>   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a> *flags;</div>
<div class="line"><a name="l00351"></a><span class="lineno">  351</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a> *timers;</div>
<div class="line"><a name="l00352"></a><span class="lineno">  352</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">clock</a> *clocks;</div>
<div class="line"><a name="l00353"></a><span class="lineno">  353</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">mutex</a> *mutexes;</div>
<div class="line"><a name="l00354"></a><span class="lineno">  354</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a> *channels;</div>
<div class="line"><a name="l00355"></a><span class="lineno">  355</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a> *mailboxes;</div>
<div class="line"><a name="l00356"></a><span class="lineno">  356</span>&#160;   <span class="keyword">static</span> <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a> *pools;</div>
<div class="line"><a name="l00357"></a><span class="lineno">  357</span>&#160;</div>
<div class="line"><a name="l00358"></a><span class="lineno">  358</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a> * f );</div>
<div class="line"><a name="l00359"></a><span class="lineno">  359</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a> * t );</div>
<div class="line"><a name="l00360"></a><span class="lineno">  360</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">clock</a> * c );</div>
<div class="line"><a name="l00361"></a><span class="lineno">  361</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">mutex</a> * m );</div>
<div class="line"><a name="l00362"></a><span class="lineno">  362</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a> * c );</div>
<div class="line"><a name="l00363"></a><span class="lineno">  363</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a> * m );</div>
<div class="line"><a name="l00364"></a><span class="lineno">  364</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> add( <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a> *p );</div>
<div class="line"><a name="l00365"></a><span class="lineno">  365</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00366"></a><span class="lineno">  366</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00367"></a><span class="lineno">  367</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00368"></a><span class="lineno">  368</span>&#160;</div>
<div class="line"><a name="l00370"></a><span class="lineno">  370</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s.html#a27731fa3169d3337e826ff0c9994c384" title="runs the scheduler">run</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00371"></a><span class="lineno">  371</span>&#160;</div>
<div class="line"><a name="l00373"></a><span class="lineno"><a class="code" href="class_r_t_o_s.html#a7e455e2e010e6af8f9f41cbeacfe6bd0">  373</a></span>&#160;   <span class="keyword">static</span> task * <a class="code" href="class_r_t_o_s.html#a7e455e2e010e6af8f9f41cbeacfe6bd0" title="returns (a pointer to) the currently executing task">current_task</a>( <span class="keywordtype">void</span> ){ <span class="keywordflow">return</span> rtos_current_task; }</div>
<div class="line"><a name="l00374"></a><span class="lineno">  374</span>&#160;</div>
<div class="line"><a name="l00376"></a><span class="lineno">  376</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s.html#a543dc322355f7277b027a3120ca13853" title="get elapsed time in micro seconds since OS startup">run_time</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00377"></a><span class="lineno">  377</span>&#160;</div>
<div class="line"><a name="l00379"></a><span class="lineno">  379</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s.html#a93b6c76a8ddc42126f9996d9c63168b8" title="prints statistics about the tasks to the stream.">print</a>( std::ostream &amp; stream );</div>
<div class="line"><a name="l00380"></a><span class="lineno">  380</span>&#160;</div>
<div class="line"><a name="l00382"></a><span class="lineno">  382</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00385"></a><span class="lineno"><a class="code" href="class_r_t_o_s.html#aa9b2602178a340b2ad59ca82d4b09b5e">  385</a></span>&#160;<span class="comment"></span>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s.html#aa9b2602178a340b2ad59ca82d4b09b5e" title="clears the statistics.">statistics_clear</a>( <span class="keywordtype">void</span> ){ must_clear = <span class="keyword">true</span>; }</div>
<div class="line"><a name="l00386"></a><span class="lineno">  386</span>&#160;</div>
<div class="line"><a name="l00388"></a><span class="lineno">  388</span>&#160;   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s.html#ace9fc0f1b35c1383b1050222706f3b70" title="print the statistics">display_statistics</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00389"></a><span class="lineno">  389</span>&#160;</div>
<div class="line"><a name="l00390"></a><span class="lineno">  390</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00391"></a><span class="lineno">  391</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00392"></a><span class="lineno">  392</span>&#160;   <span class="comment">// class event</span></div>
<div class="line"><a name="l00393"></a><span class="lineno">  393</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00395"></a><span class="lineno">  395</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00408"></a><span class="lineno">  408</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00409"></a><span class="lineno">  409</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00410"></a><span class="lineno">  410</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00411"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1event.html">  411</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> {</div>
<div class="line"><a name="l00412"></a><span class="lineno">  412</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l00413"></a><span class="lineno">  413</span>&#160;      </div>
<div class="line"><a name="l00415"></a><span class="lineno">  415</span>&#160;        <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1event.html#af3a6450c08560383db9f34b3d826d126" title="prints an event, for debugging only">print</a>( std::ostream &amp; s ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00416"></a><span class="lineno">  416</span>&#160;           </div>
<div class="line"><a name="l00418"></a><span class="lineno">  418</span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1event.html#ad8d6bd84ac8374c4ab9f9eb8579face0" title="report wether two events are the same">operator==</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> &amp; rhs ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00419"></a><span class="lineno">  419</span>&#160;      </div>
<div class="line"><a name="l00421"></a><span class="lineno">  421</span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1event.html#ad8d6bd84ac8374c4ab9f9eb8579face0" title="report wether two events are the same">operator==</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a> &amp; rhs ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00422"></a><span class="lineno">  422</span>&#160;      </div>
<div class="line"><a name="l00424"></a><span class="lineno">  424</span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1event.html#a7d5e26e1dcd4f4d43cc569188ae4ed12" title="report wether two events are not the same">operator!=</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> &amp; rhs ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00425"></a><span class="lineno">  425</span>&#160;      </div>
<div class="line"><a name="l00427"></a><span class="lineno">  427</span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1event.html#a7d5e26e1dcd4f4d43cc569188ae4ed12" title="report wether two events are not the same">operator!=</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a> &amp; rhs ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00428"></a><span class="lineno">  428</span>&#160;      </div>
<div class="line"><a name="l00430"></a><span class="lineno">  430</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00433"></a><span class="lineno">  433</span>&#160;<span class="comment"></span>      <span class="keyword">event</span> <a class="code" href="class_r_t_o_s_1_1event.html#addfcf242018d11a0f35f510d17683697" title="add two waitables, result can be used in a wait() call">operator+</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> &amp; rhs ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00434"></a><span class="lineno">  434</span>&#160;</div>
<div class="line"><a name="l00435"></a><span class="lineno">  435</span>&#160;   <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00436"></a><span class="lineno">  436</span>&#160;      </div>
<div class="line"><a name="l00438"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d">  438</a></span>&#160;      task * <a class="code" href="class_r_t_o_s_1_1event.html#a1402687edb26c1d5d26e54dbda21919d" title="the owner task">t</a>;</div>
<div class="line"><a name="l00439"></a><span class="lineno">  439</span>&#160;      </div>
<div class="line"><a name="l00441"></a><span class="lineno">  441</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00444"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1event.html#a74f6161d8c82d461ae3ba29f0e222b59">  444</a></span>&#160;<span class="comment"></span>      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1event.html#a74f6161d8c82d461ae3ba29f0e222b59" title="the mask of this event, one bit is set">mask</a>;</div>
<div class="line"><a name="l00445"></a><span class="lineno">  445</span>&#160;      </div>
<div class="line"><a name="l00447"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1event.html#a00cf9d5d01e670e2b358c2a4c7578e7d">  447</a></span>&#160;      <a class="code" href="class_r_t_o_s_1_1event.html#a00cf9d5d01e670e2b358c2a4c7578e7d" title="constructor, used by concrete events">event</a>( task * t, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1event.html#a74f6161d8c82d461ae3ba29f0e222b59" title="the mask of this event, one bit is set">mask</a> ): t( t ), mask( mask ){}</div>
<div class="line"><a name="l00448"></a><span class="lineno">  448</span>&#160;</div>
<div class="line"><a name="l00449"></a><span class="lineno">  449</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span>waitable_set;</div>
<div class="line"><a name="l00450"></a><span class="lineno">  450</span>&#160;   };</div>
<div class="line"><a name="l00451"></a><span class="lineno">  451</span>&#160;</div>
<div class="line"><a name="l00452"></a><span class="lineno">  452</span>&#160;</div>
<div class="line"><a name="l00453"></a><span class="lineno">  453</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00454"></a><span class="lineno">  454</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00455"></a><span class="lineno">  455</span>&#160;   <span class="comment">// class waitable</span></div>
<div class="line"><a name="l00456"></a><span class="lineno">  456</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00458"></a><span class="lineno">  458</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00486"></a><span class="lineno">  486</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00487"></a><span class="lineno">  487</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00488"></a><span class="lineno">  488</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00489"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1waitable.html">  489</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> {</div>
<div class="line"><a name="l00490"></a><span class="lineno">  490</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l00491"></a><span class="lineno">  491</span>&#160;</div>
<div class="line"><a name="l00493"></a><span class="lineno">  493</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00496"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1waitable.html#a44ac71980592721bc03e076acc7e8c67">  496</a></span>&#160;<span class="comment"></span>      <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1waitable.html#a44ac71980592721bc03e076acc7e8c67" title="clear the waitable">clear</a>( <span class="keywordtype">void</span> ){ t-&gt;waitables.<a class="code" href="class_r_t_o_s_1_1waitable.html#a44ac71980592721bc03e076acc7e8c67" title="clear the waitable">clear</a>( *<span class="keyword">this</span> ); }</div>
<div class="line"><a name="l00497"></a><span class="lineno">  497</span>&#160;</div>
<div class="line"><a name="l00498"></a><span class="lineno">  498</span>&#160;   <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00499"></a><span class="lineno">  499</span>&#160;      </div>
<div class="line"><a name="l00501"></a><span class="lineno">  501</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l00503"></a><span class="lineno">  503</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1waitable.html#a5a5bf9012a332a6451ee10728153908a" title="constructor, specify owner and name">waitable</a>( task * task , <span class="keyword">const</span> <span class="keywordtype">char</span> *name );</div>
<div class="line"><a name="l00504"></a><span class="lineno">  504</span>&#160;      </div>
<div class="line"><a name="l00506"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e">  506</a></span>&#160;      <span class="keywordtype">void</span> <span class="keyword">set</span> ( void ){ t-&gt;waitables.<a class="code" href="class_r_t_o_s_1_1timer.html#ae3507bb8a4384466d4b1a48098ae038f" title="set the timer to timeout after the specified time">set</a>( *<span class="keyword">this</span> ); }</div>
<div class="line"><a name="l00507"></a><span class="lineno">  507</span>&#160;</div>
<div class="line"><a name="l00508"></a><span class="lineno">  508</span>&#160;      RTOS_STATISTICS( <span class="keyword">const</span> <span class="keywordtype">char</span> *waitable_name; )</div>
<div class="line"><a name="l00509"></a><span class="lineno">  509</span>&#160;</div>
<div class="line"><a name="l00510"></a><span class="lineno">  510</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class</span> waitable_set;</div>
<div class="line"><a name="l00511"></a><span class="lineno">  511</span>&#160;   };</div>
<div class="line"><a name="l00512"></a><span class="lineno">  512</span>&#160;</div>
<div class="line"><a name="l00513"></a><span class="lineno">  513</span>&#160;</div>
<div class="line"><a name="l00514"></a><span class="lineno">  514</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00515"></a><span class="lineno">  515</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00516"></a><span class="lineno">  516</span>&#160;   <span class="comment">// class flag</span></div>
<div class="line"><a name="l00517"></a><span class="lineno">  517</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00519"></a><span class="lineno">  519</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00548"></a><span class="lineno">  548</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00549"></a><span class="lineno">  549</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00550"></a><span class="lineno">  550</span>&#160;</div>
<div class="line"><a name="l00551"></a><span class="lineno">  551</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00552"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1flag.html">  552</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a> {</div>
<div class="line"><a name="l00553"></a><span class="lineno">  553</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l00554"></a><span class="lineno">  554</span>&#160;      </div>
<div class="line"><a name="l00556"></a><span class="lineno">  556</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l00559"></a><span class="lineno">  559</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1flag.html#a2d05d296b33e6cbc141fd4fb5e6f2740" title="constructor, specify onwer and name">flag</a>( task * t, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> );</div>
<div class="line"><a name="l00560"></a><span class="lineno">  560</span>&#160;      </div>
<div class="line"><a name="l00562"></a><span class="lineno">  562</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00565"></a><span class="lineno">  565</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <span class="keyword">set</span> ( void );</div>
<div class="line"><a name="l00566"></a><span class="lineno">  566</span>&#160;      </div>
<div class="line"><a name="l00568"></a><span class="lineno">  568</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1flag.html#a38ac8e72fcd0b7bcc45fd00acb156cbb" title="prints flag infomation (for debugging)">print</a>( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00569"></a><span class="lineno">  569</span>&#160;</div>
<div class="line"><a name="l00570"></a><span class="lineno">  570</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l00571"></a><span class="lineno">  571</span>&#160;      </div>
<div class="line"><a name="l00572"></a><span class="lineno">  572</span>&#160;        <span class="comment">// this information is needed for statistics only</span></div>
<div class="line"><a name="l00573"></a><span class="lineno">  573</span>&#160;      RTOS_STATISTICS( <a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a> *next_flag; )</div>
<div class="line"><a name="l00574"></a><span class="lineno">  574</span>&#160;      RTOS_STATISTICS( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n_sets; )</div>
<div class="line"><a name="l00575"></a><span class="lineno">  575</span>&#160;      RTOS_STATISTICS( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n_gets; )</div>
<div class="line"><a name="l00576"></a><span class="lineno">  576</span>&#160;      </div>
<div class="line"><a name="l00577"></a><span class="lineno">  577</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class</span> <a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l00578"></a><span class="lineno">  578</span>&#160;   };</div>
<div class="line"><a name="l00579"></a><span class="lineno">  579</span>&#160;</div>
<div class="line"><a name="l00580"></a><span class="lineno">  580</span>&#160;</div>
<div class="line"><a name="l00581"></a><span class="lineno">  581</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00582"></a><span class="lineno">  582</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00583"></a><span class="lineno">  583</span>&#160;   <span class="comment">// class waitable_set</span></div>
<div class="line"><a name="l00584"></a><span class="lineno">  584</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00586"></a><span class="lineno">  586</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00587"></a><span class="lineno">  587</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00588"></a><span class="lineno">  588</span>&#160;</div>
<div class="line"><a name="l00589"></a><span class="lineno">  589</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00590"></a><span class="lineno">  590</span>&#160;   <span class="keyword">class </span>waitable_set {</div>
<div class="line"><a name="l00591"></a><span class="lineno">  591</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l00592"></a><span class="lineno">  592</span>&#160;      <span class="keyword">event</span> wait( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mask );</div>
<div class="line"><a name="l00593"></a><span class="lineno">  593</span>&#160;</div>
<div class="line"><a name="l00594"></a><span class="lineno">  594</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l00595"></a><span class="lineno">  595</span>&#160;      task * client;</div>
<div class="line"><a name="l00596"></a><span class="lineno">  596</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> current_waitables;</div>
<div class="line"><a name="l00597"></a><span class="lineno">  597</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> requested_waitables;</div>
<div class="line"><a name="l00598"></a><span class="lineno">  598</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> used;</div>
<div class="line"><a name="l00599"></a><span class="lineno">  599</span>&#160;</div>
<div class="line"><a name="l00600"></a><span class="lineno">  600</span>&#160;      waitable_set( task * client ):</div>
<div class="line"><a name="l00601"></a><span class="lineno">  601</span>&#160;         client( client ),</div>
<div class="line"><a name="l00602"></a><span class="lineno">  602</span>&#160;         current_waitables( 0 ),</div>
<div class="line"><a name="l00603"></a><span class="lineno">  603</span>&#160;         requested_waitables( 0 ),</div>
<div class="line"><a name="l00604"></a><span class="lineno">  604</span>&#160;         used( 0 ) {}</div>
<div class="line"><a name="l00605"></a><span class="lineno">  605</span>&#160;</div>
<div class="line"><a name="l00606"></a><span class="lineno">  606</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> waitable_allocate( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00607"></a><span class="lineno">  607</span>&#160;      <span class="keywordtype">void</span> <span class="keyword">set</span>( <span class="keyword">const</span> waitable &amp;w );</div>
<div class="line"><a name="l00608"></a><span class="lineno">  608</span>&#160;      <span class="keywordtype">void</span> clear( <span class="keyword">const</span> waitable &amp;w );</div>
<div class="line"><a name="l00609"></a><span class="lineno">  609</span>&#160;</div>
<div class="line"><a name="l00610"></a><span class="lineno">  610</span>&#160;      <span class="keyword">event</span> wait( <span class="keywordtype">void</span> ){ <span class="keywordflow">return</span> wait( ~0 ); }</div>
<div class="line"><a name="l00611"></a><span class="lineno">  611</span>&#160;      <span class="keyword">event</span> wait( <span class="keyword">const</span> waitable &amp; w ){ <span class="keywordflow">return</span> wait( w.mask ); }</div>
<div class="line"><a name="l00612"></a><span class="lineno">  612</span>&#160;      <span class="keyword">event</span> wait( <span class="keyword">const</span> event &amp; <span class="keyword">set</span> ){ <span class="keywordflow">return</span> wait( <span class="keyword">set</span>.mask ); }</div>
<div class="line"><a name="l00613"></a><span class="lineno">  613</span>&#160;   };</div>
<div class="line"><a name="l00614"></a><span class="lineno">  614</span>&#160;</div>
<div class="line"><a name="l00615"></a><span class="lineno">  615</span>&#160;</div>
<div class="line"><a name="l00616"></a><span class="lineno">  616</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00617"></a><span class="lineno">  617</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00618"></a><span class="lineno">  618</span>&#160;   <span class="comment">// class RTOS::task</span></div>
<div class="line"><a name="l00619"></a><span class="lineno">  619</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00621"></a><span class="lineno">  621</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l00781"></a><span class="lineno">  781</span>&#160;<span class="comment"></span></div>
<div class="line"><a name="l00782"></a><span class="lineno">  782</span>&#160;</div>
<div class="line"><a name="l00783"></a><span class="lineno">  783</span>&#160;   </div>
<div class="line"><a name="l00784"></a><span class="lineno">  784</span>&#160;   <span class="comment">// A task is created by inheriting</span></div>
<div class="line"><a name="l00785"></a><span class="lineno">  785</span>&#160;   <span class="comment">// from task and providing a main() function. Initialisation of the task,</span></div>
<div class="line"><a name="l00786"></a><span class="lineno">  786</span>&#160;   <span class="comment">// including creating its waitables, should be done in the constructor.</span></div>
<div class="line"><a name="l00787"></a><span class="lineno">  787</span>&#160;   <span class="comment">// Don&#39;t forget to call the constructor of the task class!</span></div>
<div class="line"><a name="l00788"></a><span class="lineno">  788</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00789"></a><span class="lineno">  789</span>&#160;   <span class="comment">// The main() is the body of the task. It should never terminate.</span></div>
<div class="line"><a name="l00790"></a><span class="lineno">  790</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00791"></a><span class="lineno">  791</span>&#160;   <span class="comment">// Each task has a unique priority (an unsigned integer).</span></div>
<div class="line"><a name="l00792"></a><span class="lineno">  792</span>&#160;   <span class="comment">// A lower value indicates a higher priority.</span></div>
<div class="line"><a name="l00793"></a><span class="lineno">  793</span>&#160;   <span class="comment">// The RTOS scheduler will always run the task with the higest-priority</span></div>
<div class="line"><a name="l00794"></a><span class="lineno">  794</span>&#160;   <span class="comment">// runnable (neither blocked nor suspended) task.</span></div>
<div class="line"><a name="l00795"></a><span class="lineno">  795</span>&#160;   <span class="comment">// A task runs until it changes this &#39;situation&#39; by using an RTOS</span></div>
<div class="line"><a name="l00796"></a><span class="lineno">  796</span>&#160;   <span class="comment">// call that changes its own state to not runnable, or the state of a</span></div>
<div class="line"><a name="l00797"></a><span class="lineno">  797</span>&#160;   <span class="comment">// higher priority task to runnable.</span></div>
<div class="line"><a name="l00798"></a><span class="lineno">  798</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00799"></a><span class="lineno">  799</span>&#160;   <span class="comment">// Timers are served only when the RTOS is activated</span></div>
<div class="line"><a name="l00800"></a><span class="lineno">  800</span>&#160;   <span class="comment">// by calling any of its state-changing interfaces.</span></div>
<div class="line"><a name="l00801"></a><span class="lineno">  801</span>&#160;   <span class="comment">// Hence the longest run time between such calls determines the granularity</span></div>
<div class="line"><a name="l00802"></a><span class="lineno">  802</span>&#160;   <span class="comment">// (timewise responsiveness) of the application.</span></div>
<div class="line"><a name="l00803"></a><span class="lineno">  803</span>&#160;   <span class="comment">// Within a timeconsuming computation a task can call release() to have</span></div>
<div class="line"><a name="l00804"></a><span class="lineno">  804</span>&#160;   <span class="comment">// the RTOS serve the timers.   </span></div>
<div class="line"><a name="l00805"></a><span class="lineno">  805</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l00806"></a><span class="lineno">  806</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l00807"></a><span class="lineno">  807</span>&#160;</div>
<div class="line"><a name="l00808"></a><span class="lineno">  808</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00809"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html">  809</a></span>&#160;   <span class="keyword">class </span>task {</div>
<div class="line"><a name="l00810"></a><span class="lineno">  810</span>&#160;</div>
<div class="line"><a name="l00811"></a><span class="lineno">  811</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l00812"></a><span class="lineno">  812</span>&#160;</div>
<div class="line"><a name="l00813"></a><span class="lineno">  813</span>&#160;         <span class="comment">// The RTOS uses block() and unblock() to implement the</span></div>
<div class="line"><a name="l00814"></a><span class="lineno">  814</span>&#160;         <span class="comment">// synhronisation mechanisms (waitables).</span></div>
<div class="line"><a name="l00815"></a><span class="lineno">  815</span>&#160;      <span class="keywordtype">bool</span> task_is_blocked;</div>
<div class="line"><a name="l00816"></a><span class="lineno">  816</span>&#160;</div>
<div class="line"><a name="l00817"></a><span class="lineno">  817</span>&#160;         <span class="comment">// A task can be suspended and resumed by the application,</span></div>
<div class="line"><a name="l00818"></a><span class="lineno">  818</span>&#160;         <span class="comment">// using the suspend() and resume() calls.</span></div>
<div class="line"><a name="l00819"></a><span class="lineno">  819</span>&#160;         <span class="comment">// The RTOS itself never suspends or resumes a task.</span></div>
<div class="line"><a name="l00820"></a><span class="lineno">  820</span>&#160;      <span class="keywordtype">bool</span> task_is_suspended;</div>
<div class="line"><a name="l00821"></a><span class="lineno">  821</span>&#160;</div>
<div class="line"><a name="l00822"></a><span class="lineno">  822</span>&#160;         <span class="comment">// task name, only for statistics</span></div>
<div class="line"><a name="l00823"></a><span class="lineno">  823</span>&#160;      RTOS_STATISTICS( <span class="keyword">const</span> <span class="keywordtype">char</span> *task_name; )</div>
<div class="line"><a name="l00824"></a><span class="lineno">  824</span>&#160;</div>
<div class="line"><a name="l00825"></a><span class="lineno">  825</span>&#160;         <span class="comment">// a lower number means a higher priority, 0 is highest</span></div>
<div class="line"><a name="l00826"></a><span class="lineno">  826</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> task_priority;</div>
<div class="line"><a name="l00827"></a><span class="lineno">  827</span>&#160;</div>
<div class="line"><a name="l00828"></a><span class="lineno">  828</span>&#160;         <span class="comment">// timer for sleep() call</span></div>
<div class="line"><a name="l00829"></a><span class="lineno">  829</span>&#160;      <a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a> * sleep_timer;</div>
<div class="line"><a name="l00830"></a><span class="lineno">  830</span>&#160;</div>
<div class="line"><a name="l00831"></a><span class="lineno">  831</span>&#160;   <span class="keyword">protected</span>:</div>
<div class="line"><a name="l00832"></a><span class="lineno">  832</span>&#160;</div>
<div class="line"><a name="l00834"></a><span class="lineno">  834</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00857"></a><span class="lineno">  857</span>&#160;<span class="comment"></span>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#addc6d52f8792ddba1158d7ae5ef0037d" title="task body, must be provided by a derived class">main</a>( <span class="keywordtype">void</span> ) = 0;</div>
<div class="line"><a name="l00858"></a><span class="lineno">  858</span>&#160;      </div>
<div class="line"><a name="l00859"></a><span class="lineno">  859</span>&#160;   <span class="keyword">private</span>:   </div>
<div class="line"><a name="l00860"></a><span class="lineno">  860</span>&#160;</div>
<div class="line"><a name="l00861"></a><span class="lineno">  861</span>&#160;      <span class="comment">// must call main()</span></div>
<div class="line"><a name="l00862"></a><span class="lineno">  862</span>&#160;      <span class="keyword">friend</span> <span class="keywordtype">void</span> task_trampoline( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00863"></a><span class="lineno">  863</span>&#160;</div>
<div class="line"><a name="l00864"></a><span class="lineno">  864</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l00865"></a><span class="lineno">  865</span>&#160;</div>
<div class="line"><a name="l00867"></a><span class="lineno">  867</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00878"></a><span class="lineno">  878</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1task.html#ae50f0e253e66c53e3b28e388133c8fe7" title="constructor, specify priority, name and stacksize">task</a>(</div>
<div class="line"><a name="l00879"></a><span class="lineno">  879</span>&#160;         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1task.html#ac5a30dff650f3b714491509cabad5dff" title="report the task priority">priority</a>  = RTOS_MAX_PRIORITY,</div>
<div class="line"><a name="l00880"></a><span class="lineno">  880</span>&#160;         <span class="keyword">const</span> <span class="keywordtype">char</span> * tname     = <span class="stringliteral">&quot;&quot;</span>,</div>
<div class="line"><a name="l00881"></a><span class="lineno">  881</span>&#160;         <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> stacksize = RTOS_DEFAULT_STACK_SIZE</div>
<div class="line"><a name="l00882"></a><span class="lineno">  882</span>&#160;      );</div>
<div class="line"><a name="l00883"></a><span class="lineno">  883</span>&#160;</div>
<div class="line"><a name="l00885"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a5035326ddaf51d9219a17ca6c5a23c83">  885</a></span>&#160;      <a class="code" href="class_r_t_o_s_1_1task.html#a5035326ddaf51d9219a17ca6c5a23c83" title="throws an error, beacuse tasks should never be destroyed">~task</a> ( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l00886"></a><span class="lineno">  886</span>&#160;         mkt_fatal (#UNIQUE_ERROR); <span class="comment">// task destructor called</span></div>
<div class="line"><a name="l00887"></a><span class="lineno">  887</span>&#160;      }</div>
<div class="line"><a name="l00888"></a><span class="lineno">  888</span>&#160;</div>
<div class="line"><a name="l00890"></a><span class="lineno">  890</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00896"></a><span class="lineno">  896</span>&#160;<span class="comment"></span>      <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#a2e0e3c92d9479336535a2ef877103f36" title="suspend a task (prevent execution until a resume)">suspend</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00897"></a><span class="lineno">  897</span>&#160;      </div>
<div class="line"><a name="l00899"></a><span class="lineno">  899</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00900"></a><span class="lineno">  900</span>&#160;      <span class="comment">// Resumes the task (cancels a suspension).  </span></div>
<div class="line"><a name="l00904"></a><span class="lineno">  904</span>&#160;<span class="comment"></span>      <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#a841b14aaab18d883959f034510dd9376" title="continue a suspended task">resume</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00905"></a><span class="lineno">  905</span>&#160;</div>
<div class="line"><a name="l00907"></a><span class="lineno">  907</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00910"></a><span class="lineno">  910</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#aa3eec7220a2724d30e2156cc395035f2" title="release the CPU to the scheduler">release</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00911"></a><span class="lineno">  911</span>&#160;</div>
<div class="line"><a name="l00913"></a><span class="lineno">  913</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00915"></a><span class="lineno">  915</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#a9d639b6f1147e0e3dbc603cdd8c52bd4" title="wait for some time">sleep</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> time );</div>
<div class="line"><a name="l00916"></a><span class="lineno">  916</span>&#160;</div>
<div class="line"><a name="l00918"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#ac5a30dff650f3b714491509cabad5dff">  918</a></span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1task.html#ac5a30dff650f3b714491509cabad5dff" title="report the task priority">priority</a>( <span class="keywordtype">void</span> )<span class="keyword"> const   </span>{ <span class="keywordflow">return</span> task_priority; }</div>
<div class="line"><a name="l00919"></a><span class="lineno">  919</span>&#160;      </div>
<div class="line"><a name="l00921"></a><span class="lineno">  921</span>&#160;      <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="class_r_t_o_s_1_1task.html#a56e4d07750c49b6620b0407013b177c1" title="report the task name">name</a>( <span class="keywordtype">void</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00922"></a><span class="lineno">  922</span>&#160;      </div>
<div class="line"><a name="l00924"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#ab02fe6432956956957bb2629dc9a3031">  924</a></span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1task.html#ab02fe6432956956957bb2629dc9a3031" title="report whether the task is currently suspended">is_suspended</a>( <span class="keywordtype">void</span> )<span class="keyword"> const       </span>{ <span class="keywordflow">return</span> task_is_suspended; }</div>
<div class="line"><a name="l00925"></a><span class="lineno">  925</span>&#160;      </div>
<div class="line"><a name="l00927"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a1e0b2566b673b0e4e6efd63a80284d35">  927</a></span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1task.html#a1e0b2566b673b0e4e6efd63a80284d35" title="report whether the task is currently blocked">is_blocked</a>( <span class="keywordtype">void</span> )<span class="keyword"> const         </span>{ <span class="keywordflow">return</span> task_is_blocked; }</div>
<div class="line"><a name="l00928"></a><span class="lineno">  928</span>&#160;      </div>
<div class="line"><a name="l00930"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a8ec666474a7668f78da3438dfa818a8e">  930</a></span>&#160;      <span class="keywordtype">bool</span> <a class="code" href="class_r_t_o_s_1_1task.html#a8ec666474a7668f78da3438dfa818a8e" title="report whether the task is currently ready for execution">is_ready</a>( <span class="keywordtype">void</span> )<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00931"></a><span class="lineno">  931</span>&#160;         <span class="keywordflow">return</span> !( task_is_suspended || task_is_blocked );</div>
<div class="line"><a name="l00932"></a><span class="lineno">  932</span>&#160;      }</div>
<div class="line"><a name="l00933"></a><span class="lineno">  933</span>&#160;</div>
<div class="line"><a name="l00935"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a76913289a89a86fcf40171e28bfcfe98">  935</a></span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#a76913289a89a86fcf40171e28bfcfe98" title="for debugging: switch logging on or off">logging_set</a>( <span class="keywordtype">bool</span> log ) { logging = log; }</div>
<div class="line"><a name="l00936"></a><span class="lineno">  936</span>&#160;</div>
<div class="line"><a name="l00938"></a><span class="lineno">  938</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#ac94209dd2efea030a70d48dabc890f38" title="print task statistics">print</a>( std::ostream &amp; stream, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l00939"></a><span class="lineno">  939</span>&#160;                  </div>
<div class="line"><a name="l00941"></a><span class="lineno">  941</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00954"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a6fc603d0f1c8a94813586d3dfd123fcc">  954</a></span>&#160;<span class="comment"></span>      <span class="keyword">event</span> <a class="code" href="class_r_t_o_s_1_1task.html#a6fc603d0f1c8a94813586d3dfd123fcc" title="wait for all waitables created for this task">wait</a>( <span class="keywordtype">void</span> ){ <span class="keywordflow">return</span> waitables.wait(); }</div>
<div class="line"><a name="l00955"></a><span class="lineno">  955</span>&#160;      </div>
<div class="line"><a name="l00957"></a><span class="lineno">  957</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00959"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a7b20fada91e6d232f6791ebc9675e3fc">  959</a></span>&#160;<span class="comment"></span>      <span class="keyword">event</span> <a class="code" href="class_r_t_o_s_1_1task.html#a7b20fada91e6d232f6791ebc9675e3fc" title="wait for a single waitable">wait</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a> &amp; w ){ <span class="keywordflow">return</span> waitables.wait( w ); }</div>
<div class="line"><a name="l00960"></a><span class="lineno">  960</span>&#160;      </div>
<div class="line"><a name="l00962"></a><span class="lineno">  962</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00964"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a09111916c62632df3042f5991ac7ab42">  964</a></span>&#160;<span class="comment"></span>      <span class="keyword">event</span> <a class="code" href="class_r_t_o_s_1_1task.html#a09111916c62632df3042f5991ac7ab42" title="wait for a set of waitables">wait</a>( <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">event</a> &amp; <span class="keyword">set</span> ){ <span class="keywordflow">return</span> waitables.wait( <span class="keyword">set</span> ); }</div>
<div class="line"><a name="l00965"></a><span class="lineno">  965</span>&#160;</div>
<div class="line"><a name="l00967"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#aebeb5ca826f7137a66474bbee3bf74a1">  967</a></span>&#160;      <span class="keywordtype">void</span> <span class="keyword">set</span>( <a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">flag</a> &amp;w ){ w.set(); }</div>
<div class="line"><a name="l00968"></a><span class="lineno">  968</span>&#160;</div>
<div class="line"><a name="l00970"></a><span class="lineno">  970</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l00977"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1task.html#a0ea383a40c40d9f69fe8e29fb36fa40d">  977</a></span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1task.html#a0ea383a40c40d9f69fe8e29fb36fa40d" title="ignore this activation for the statistics">ignore_activation_time</a>( <span class="keywordtype">void</span> ){</div>
<div class="line"><a name="l00978"></a><span class="lineno">  978</span>&#160;         ignore_this_activation = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00979"></a><span class="lineno">  979</span>&#160;      }</div>
<div class="line"><a name="l00980"></a><span class="lineno">  980</span>&#160;</div>
<div class="line"><a name="l00981"></a><span class="lineno">  981</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l00982"></a><span class="lineno">  982</span>&#160;</div>
<div class="line"><a name="l00984"></a><span class="lineno">  984</span>&#160;      <span class="keywordtype">void</span> statistics_clear( <span class="keywordtype">void</span> ){</div>
<div class="line"><a name="l00985"></a><span class="lineno">  985</span>&#160;         runtime_max = 0;</div>
<div class="line"><a name="l00986"></a><span class="lineno">  986</span>&#160;         activations = 0;</div>
<div class="line"><a name="l00987"></a><span class="lineno">  987</span>&#160;      }</div>
<div class="line"><a name="l00988"></a><span class="lineno">  988</span>&#160;</div>
<div class="line"><a name="l00990"></a><span class="lineno">  990</span>&#160;      waitable_set waitables;</div>
<div class="line"><a name="l00991"></a><span class="lineno">  991</span>&#160;</div>
<div class="line"><a name="l00993"></a><span class="lineno">  993</span>&#160;      <span class="keywordtype">void</span> block( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00994"></a><span class="lineno">  994</span>&#160;</div>
<div class="line"><a name="l00996"></a><span class="lineno">  996</span>&#160;      <span class="keywordtype">void</span> unblock( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l00997"></a><span class="lineno">  997</span>&#160;</div>
<div class="line"><a name="l00999"></a><span class="lineno">  999</span>&#160;      <span class="keywordtype">int</span> activated;</div>
<div class="line"><a name="l01000"></a><span class="lineno"> 1000</span>&#160;      <span class="keywordtype">int</span> latency_max;</div>
<div class="line"><a name="l01001"></a><span class="lineno"> 1001</span>&#160;      <span class="keywordtype">int</span> runtime_max;</div>
<div class="line"><a name="l01002"></a><span class="lineno"> 1002</span>&#160;      <span class="keywordtype">int</span> activations;</div>
<div class="line"><a name="l01003"></a><span class="lineno"> 1003</span>&#160;      <span class="keywordtype">bool</span> ignore_this_activation;</div>
<div class="line"><a name="l01004"></a><span class="lineno"> 1004</span>&#160;</div>
<div class="line"><a name="l01006"></a><span class="lineno"> 1006</span>&#160;      <span class="keywordtype">bool</span> logging;</div>
<div class="line"><a name="l01007"></a><span class="lineno"> 1007</span>&#160;</div>
<div class="line"><a name="l01009"></a><span class="lineno"> 1009</span>&#160;      <span class="keywordtype">void</span> debug( <span class="keyword">const</span> <span class="keywordtype">char</span> * msg );</div>
<div class="line"><a name="l01010"></a><span class="lineno"> 1010</span>&#160;</div>
<div class="line"><a name="l01012"></a><span class="lineno"> 1012</span>&#160;      task * nextTask;</div>
<div class="line"><a name="l01013"></a><span class="lineno"> 1013</span>&#160;</div>
<div class="line"><a name="l01015"></a><span class="lineno"> 1015</span>&#160;      task * next_mutex_waiter;</div>
<div class="line"><a name="l01016"></a><span class="lineno"> 1016</span>&#160;</div>
<div class="line"><a name="l01018"></a><span class="lineno"> 1018</span>&#160;      mkt_coroutine_class *coroutine;</div>
<div class="line"><a name="l01019"></a><span class="lineno"> 1019</span>&#160;</div>
<div class="line"><a name="l01020"></a><span class="lineno"> 1020</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span>periodic_task;</div>
<div class="line"><a name="l01021"></a><span class="lineno"> 1021</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span>waitable_set;</div>
<div class="line"><a name="l01022"></a><span class="lineno"> 1022</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span>flag;</div>
<div class="line"><a name="l01023"></a><span class="lineno"> 1023</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01024"></a><span class="lineno"> 1024</span>&#160;   };</div>
<div class="line"><a name="l01025"></a><span class="lineno"> 1025</span>&#160;</div>
<div class="line"><a name="l01026"></a><span class="lineno"> 1026</span>&#160;</div>
<div class="line"><a name="l01027"></a><span class="lineno"> 1027</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01028"></a><span class="lineno"> 1028</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01029"></a><span class="lineno"> 1029</span>&#160;   <span class="comment">// class callback</span></div>
<div class="line"><a name="l01030"></a><span class="lineno"> 1030</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01032"></a><span class="lineno"> 1032</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01033"></a><span class="lineno"> 1033</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01034"></a><span class="lineno"> 1034</span>&#160;</div>
<div class="line"><a name="l01035"></a><span class="lineno"> 1035</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l01036"></a><span class="lineno"> 1036</span>&#160;   <span class="keyword">class </span>callback {</div>
<div class="line"><a name="l01037"></a><span class="lineno"> 1037</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01038"></a><span class="lineno"> 1038</span>&#160;</div>
<div class="line"><a name="l01039"></a><span class="lineno"> 1039</span>&#160;      callback( <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> );</div>
<div class="line"><a name="l01040"></a><span class="lineno"> 1040</span>&#160;</div>
<div class="line"><a name="l01041"></a><span class="lineno"> 1041</span>&#160;      <span class="comment">// a timer should never be destroyed</span></div>
<div class="line"><a name="l01042"></a><span class="lineno"> 1042</span>&#160;      ~callback( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l01043"></a><span class="lineno"> 1043</span>&#160;         mkt_fatal (#UNIQUE_ERROR); <span class="comment">// callback_timer destructor called</span></div>
<div class="line"><a name="l01044"></a><span class="lineno"> 1044</span>&#160;      }</div>
<div class="line"><a name="l01045"></a><span class="lineno"> 1045</span>&#160;</div>
<div class="line"><a name="l01046"></a><span class="lineno"> 1046</span>&#160;      <span class="comment">// a timer&#39;s time_up function must be provided by a derived class</span></div>
<div class="line"><a name="l01047"></a><span class="lineno"> 1047</span>&#160;      <span class="keyword">virtual</span> <span class="keywordtype">void</span> time_up (<span class="keywordtype">void</span>) = 0;</div>
<div class="line"><a name="l01048"></a><span class="lineno"> 1048</span>&#160;</div>
<div class="line"><a name="l01049"></a><span class="lineno"> 1049</span>&#160;   <span class="keyword">protected</span>:</div>
<div class="line"><a name="l01050"></a><span class="lineno"> 1050</span>&#160;      <span class="comment">// the callback must fire &lt;time&gt; from now</span></div>
<div class="line"><a name="l01051"></a><span class="lineno"> 1051</span>&#160;      <span class="keywordtype">void</span> start( <span class="keywordtype">long</span> <span class="keywordtype">int</span> time ){ time_to_wait = time; }</div>
<div class="line"><a name="l01052"></a><span class="lineno"> 1052</span>&#160;</div>
<div class="line"><a name="l01053"></a><span class="lineno"> 1053</span>&#160;      <span class="comment">// the callback must fire &lt;time&gt; from the last firing</span></div>
<div class="line"><a name="l01054"></a><span class="lineno"> 1054</span>&#160;      <span class="keywordtype">void</span> restart( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> time ){</div>
<div class="line"><a name="l01055"></a><span class="lineno"> 1055</span>&#160;         <span class="keywordflow">while</span>( time_to_wait &lt;= 0 ){ time_to_wait += time; }</div>
<div class="line"><a name="l01056"></a><span class="lineno"> 1056</span>&#160;      }</div>
<div class="line"><a name="l01057"></a><span class="lineno"> 1057</span>&#160;</div>
<div class="line"><a name="l01058"></a><span class="lineno"> 1058</span>&#160;      <span class="comment">// abort a started timer</span></div>
<div class="line"><a name="l01059"></a><span class="lineno"> 1059</span>&#160;      <span class="keyword">virtual</span> <span class="keywordtype">void</span> cancel( <span class="keywordtype">void</span> ){ time_to_wait = 0; }</div>
<div class="line"><a name="l01060"></a><span class="lineno"> 1060</span>&#160;</div>
<div class="line"><a name="l01061"></a><span class="lineno"> 1061</span>&#160;      RTOS_STATISTICS( <span class="keyword">const</span> <span class="keywordtype">char</span> * object_name; )</div>
<div class="line"><a name="l01062"></a><span class="lineno"> 1062</span>&#160;</div>
<div class="line"><a name="l01063"></a><span class="lineno"> 1063</span>&#160;         <span class="comment">// the number of microseconds until the next time_up</span></div>
<div class="line"><a name="l01064"></a><span class="lineno"> 1064</span>&#160;      <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> time_to_wait;</div>
<div class="line"><a name="l01065"></a><span class="lineno"> 1065</span>&#160;</div>
<div class="line"><a name="l01066"></a><span class="lineno"> 1066</span>&#160;         <span class="comment">// called by the RTOS to state that &lt;elapsed&gt; time has elapsed</span></div>
<div class="line"><a name="l01067"></a><span class="lineno"> 1067</span>&#160;      <span class="keywordtype">void</span> tick( <span class="keywordtype">int</span> elapsed );</div>
<div class="line"><a name="l01068"></a><span class="lineno"> 1068</span>&#160;</div>
<div class="line"><a name="l01069"></a><span class="lineno"> 1069</span>&#160;         <span class="comment">// for the RTOS to link timers in a chain</span></div>
<div class="line"><a name="l01070"></a><span class="lineno"> 1070</span>&#160;      callback * nextTimer;</div>
<div class="line"><a name="l01071"></a><span class="lineno"> 1071</span>&#160;</div>
<div class="line"><a name="l01072"></a><span class="lineno"> 1072</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01073"></a><span class="lineno"> 1073</span>&#160;   };</div>
<div class="line"><a name="l01074"></a><span class="lineno"> 1074</span>&#160;</div>
<div class="line"><a name="l01075"></a><span class="lineno"> 1075</span>&#160;</div>
<div class="line"><a name="l01076"></a><span class="lineno"> 1076</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01077"></a><span class="lineno"> 1077</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01078"></a><span class="lineno"> 1078</span>&#160;   <span class="comment">// class timer</span></div>
<div class="line"><a name="l01079"></a><span class="lineno"> 1079</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01081"></a><span class="lineno"> 1081</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01104"></a><span class="lineno"> 1104</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01105"></a><span class="lineno"> 1105</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01106"></a><span class="lineno"> 1106</span>&#160;</div>
<div class="line"><a name="l01107"></a><span class="lineno"> 1107</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01108"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1timer.html"> 1108</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a>, <span class="keyword">public</span> callback {</div>
<div class="line"><a name="l01109"></a><span class="lineno"> 1109</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01110"></a><span class="lineno"> 1110</span>&#160;      </div>
<div class="line"><a name="l01112"></a><span class="lineno"> 1112</span>&#160;      <a class="code" href="class_r_t_o_s_1_1timer.html#a5a2a759e35dd9d7cea8971db60fbe741" title="create a timer for task t, specify its name">timer</a>( task * t, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> );</div>
<div class="line"><a name="l01113"></a><span class="lineno"> 1113</span>&#160;      </div>
<div class="line"><a name="l01115"></a><span class="lineno"> 1115</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01120"></a><span class="lineno"> 1120</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <span class="keyword">set</span>( <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> time );</div>
<div class="line"><a name="l01121"></a><span class="lineno"> 1121</span>&#160;      </div>
<div class="line"><a name="l01123"></a><span class="lineno"> 1123</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01126"></a><span class="lineno"> 1126</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1timer.html#a6df8dddc38d933432131efba05168d10" title="stop and clear the timer">cancel</a>( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l01127"></a><span class="lineno"> 1127</span>&#160;</div>
<div class="line"><a name="l01129"></a><span class="lineno"> 1129</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1timer.html#aca6725d409de3630e4b8b7883dacbc4f" title="print the timer (for debugging)">print</a>( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01130"></a><span class="lineno"> 1130</span>&#160;</div>
<div class="line"><a name="l01131"></a><span class="lineno"> 1131</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01132"></a><span class="lineno"> 1132</span>&#160;      <span class="keywordtype">void</span> time_up( <span class="keywordtype">void</span> ){ <a class="code" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e" title="set the waitable">waitable::set</a>(); }</div>
<div class="line"><a name="l01133"></a><span class="lineno"> 1133</span>&#160;      RTOS_STATISTICS( <a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">timer</a> *next_timer; )</div>
<div class="line"><a name="l01134"></a><span class="lineno"> 1134</span>&#160;      RTOS_STATISTICS( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n_sets; )</div>
<div class="line"><a name="l01135"></a><span class="lineno"> 1135</span>&#160;      RTOS_STATISTICS( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> n_cancels; )</div>
<div class="line"><a name="l01136"></a><span class="lineno"> 1136</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class</span> <a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01137"></a><span class="lineno"> 1137</span>&#160;   };</div>
<div class="line"><a name="l01138"></a><span class="lineno"> 1138</span>&#160;</div>
<div class="line"><a name="l01139"></a><span class="lineno"> 1139</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01140"></a><span class="lineno"> 1140</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01141"></a><span class="lineno"> 1141</span>&#160;   <span class="comment">// class clock</span></div>
<div class="line"><a name="l01142"></a><span class="lineno"> 1142</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01144"></a><span class="lineno"> 1144</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01161"></a><span class="lineno"> 1161</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01162"></a><span class="lineno"> 1162</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01163"></a><span class="lineno"> 1163</span>&#160;</div>
<div class="line"><a name="l01164"></a><span class="lineno"> 1164</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01165"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1clock.html"> 1165</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">clock</a> :  <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a>, <span class="keyword">public</span> callback {</div>
<div class="line"><a name="l01166"></a><span class="lineno"> 1166</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01167"></a><span class="lineno"> 1167</span>&#160;      </div>
<div class="line"><a name="l01169"></a><span class="lineno"> 1169</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l01171"></a><span class="lineno"> 1171</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1clock.html#acddd4420f67c5af6e130ca177526d148" title="create a clock for task t, specify interval and name">clock</a>( </div>
<div class="line"><a name="l01172"></a><span class="lineno"> 1172</span>&#160;         task * t, </div>
<div class="line"><a name="l01173"></a><span class="lineno"> 1173</span>&#160;         <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1clock.html#aeef3e995e7334fc203f0062e532a5804" title="the interval of the timer">interval</a>, </div>
<div class="line"><a name="l01174"></a><span class="lineno"> 1174</span>&#160;         <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> </div>
<div class="line"><a name="l01175"></a><span class="lineno"> 1175</span>&#160;      );</div>
<div class="line"><a name="l01176"></a><span class="lineno"> 1176</span>&#160;      </div>
<div class="line"><a name="l01178"></a><span class="lineno"> 1178</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01180"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1clock.html#a90d7c2b274fff1b43a1de08e742c41c3"> 1180</a></span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1clock.html#a90d7c2b274fff1b43a1de08e742c41c3" title="clear the waitable within the clock">clear</a>( <span class="keywordtype">void</span> ){ <a class="code" href="class_r_t_o_s_1_1clock.html#a90d7c2b274fff1b43a1de08e742c41c3" title="clear the waitable within the clock">waitable::clear</a>(); }</div>
<div class="line"><a name="l01181"></a><span class="lineno"> 1181</span>&#160;         </div>
<div class="line"><a name="l01183"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1clock.html#aeef3e995e7334fc203f0062e532a5804"> 1183</a></span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="class_r_t_o_s_1_1clock.html#aeef3e995e7334fc203f0062e532a5804" title="the interval of the timer">interval</a>( <span class="keywordtype">void</span> ){ <span class="keywordflow">return</span> _interval; }</div>
<div class="line"><a name="l01184"></a><span class="lineno"> 1184</span>&#160;</div>
<div class="line"><a name="l01186"></a><span class="lineno"> 1186</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1clock.html#ad2d6da1595d84cbcc93cb73ed888a72a" title="print the clock (for debugging)">print</a>( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01187"></a><span class="lineno"> 1187</span>&#160;</div>
<div class="line"><a name="l01188"></a><span class="lineno"> 1188</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01189"></a><span class="lineno"> 1189</span>&#160;      <span class="keywordtype">void</span> time_up( <span class="keywordtype">void</span> );</div>
<div class="line"><a name="l01190"></a><span class="lineno"> 1190</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> _interval;</div>
<div class="line"><a name="l01191"></a><span class="lineno"> 1191</span>&#160;      RTOS_STATISTICS( <a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">clock</a> *next_clock; )</div>
<div class="line"><a name="l01192"></a><span class="lineno"> 1192</span>&#160;      RTOS_STATISTICS( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ticks; )</div>
<div class="line"><a name="l01193"></a><span class="lineno"> 1193</span>&#160;</div>
<div class="line"><a name="l01194"></a><span class="lineno"> 1194</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class</span> <a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01195"></a><span class="lineno"> 1195</span>&#160;   };</div>
<div class="line"><a name="l01196"></a><span class="lineno"> 1196</span>&#160;</div>
<div class="line"><a name="l01197"></a><span class="lineno"> 1197</span>&#160;</div>
<div class="line"><a name="l01198"></a><span class="lineno"> 1198</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01199"></a><span class="lineno"> 1199</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01200"></a><span class="lineno"> 1200</span>&#160;   <span class="comment">// class pool_base</span></div>
<div class="line"><a name="l01201"></a><span class="lineno"> 1201</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01203"></a><span class="lineno"> 1203</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01204"></a><span class="lineno"> 1204</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01205"></a><span class="lineno"> 1205</span>&#160;</div>
<div class="line"><a name="l01206"></a><span class="lineno"> 1206</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01207"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1pool__base.html"> 1207</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a> {</div>
<div class="line"><a name="l01208"></a><span class="lineno"> 1208</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01209"></a><span class="lineno"> 1209</span>&#160;      <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> * name );</div>
<div class="line"><a name="l01210"></a><span class="lineno"> 1210</span>&#160;      ~<a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a>( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l01211"></a><span class="lineno"> 1211</span>&#160;         mkt_fatal (#UNIQUE_ERROR); <span class="comment">// pool destructor called</span></div>
<div class="line"><a name="l01212"></a><span class="lineno"> 1212</span>&#160;      }</div>
<div class="line"><a name="l01213"></a><span class="lineno"> 1213</span>&#160;      <span class="keywordtype">void</span> print( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01214"></a><span class="lineno"> 1214</span>&#160;</div>
<div class="line"><a name="l01215"></a><span class="lineno"> 1215</span>&#160;<span class="preprocessor">   #if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l01216"></a><span class="lineno"> 1216</span>&#160;<span class="preprocessor"></span>      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> reads;</div>
<div class="line"><a name="l01217"></a><span class="lineno"> 1217</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> writes;</div>
<div class="line"><a name="l01218"></a><span class="lineno"> 1218</span>&#160;      <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a> * next_pool;</div>
<div class="line"><a name="l01219"></a><span class="lineno"> 1219</span>&#160;      <span class="keyword">const</span> <span class="keywordtype">char</span> * pool_name;</div>
<div class="line"><a name="l01220"></a><span class="lineno"> 1220</span>&#160;<span class="preprocessor">   #endif</span></div>
<div class="line"><a name="l01221"></a><span class="lineno"> 1221</span>&#160;<span class="preprocessor"></span>      <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01222"></a><span class="lineno"> 1222</span>&#160;   };</div>
<div class="line"><a name="l01223"></a><span class="lineno"> 1223</span>&#160;</div>
<div class="line"><a name="l01224"></a><span class="lineno"> 1224</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01225"></a><span class="lineno"> 1225</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01226"></a><span class="lineno"> 1226</span>&#160;   <span class="comment">// class pool</span></div>
<div class="line"><a name="l01227"></a><span class="lineno"> 1227</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01229"></a><span class="lineno"> 1229</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01268"></a><span class="lineno"> 1268</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01269"></a><span class="lineno"> 1269</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01270"></a><span class="lineno"> 1270</span>&#160;</div>
<div class="line"><a name="l01271"></a><span class="lineno"> 1271</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01272"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1pool.html"> 1272</a></span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1pool.html" title="place to store and rectrieve data, no built-in synchronisation">pool</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a> {</div>
<div class="line"><a name="l01273"></a><span class="lineno"> 1273</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01274"></a><span class="lineno"> 1274</span>&#160;      </div>
<div class="line"><a name="l01276"></a><span class="lineno"> 1276</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l01282"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1pool.html#a34dfd08a46f1fd274f1692469eebaf36"> 1282</a></span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1pool.html#a34dfd08a46f1fd274f1692469eebaf36" title="construct a pool, specify its name (for debgging only)">pool</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> ): <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">pool_base</a>( name ){}</div>
<div class="line"><a name="l01283"></a><span class="lineno"> 1283</span>&#160;</div>
<div class="line"><a name="l01285"></a><span class="lineno"> 1285</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01293"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1pool.html#a2bd2a2bfb99d74c8b123de344698ff53"> 1293</a></span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1pool.html#a2bd2a2bfb99d74c8b123de344698ff53" title="atomic write operation on a pool">write</a> (T item) {</div>
<div class="line"><a name="l01294"></a><span class="lineno"> 1294</span>&#160;         RTOS_STATISTICS( reads++; )</div>
<div class="line"><a name="l01295"></a><span class="lineno"> 1295</span>&#160;         data = item;</div>
<div class="line"><a name="l01296"></a><span class="lineno"> 1296</span>&#160;      }</div>
<div class="line"><a name="l01297"></a><span class="lineno"> 1297</span>&#160;</div>
<div class="line"><a name="l01299"></a><span class="lineno"> 1299</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01301"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1pool.html#a0ef6382b71ae141cf38f477c8bfea325"> 1301</a></span>&#160;<span class="comment"></span>      T <a class="code" href="class_r_t_o_s_1_1pool.html#a0ef6382b71ae141cf38f477c8bfea325" title="atomic read operation on a pool">read</a> (<span class="keywordtype">void</span>) {</div>
<div class="line"><a name="l01302"></a><span class="lineno"> 1302</span>&#160;         RTOS_STATISTICS( writes++; )</div>
<div class="line"><a name="l01303"></a><span class="lineno"> 1303</span>&#160;         <span class="keywordflow">return</span> data;</div>
<div class="line"><a name="l01304"></a><span class="lineno"> 1304</span>&#160;      }</div>
<div class="line"><a name="l01305"></a><span class="lineno"> 1305</span>&#160;</div>
<div class="line"><a name="l01306"></a><span class="lineno"> 1306</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01307"></a><span class="lineno"> 1307</span>&#160;      T data;</div>
<div class="line"><a name="l01308"></a><span class="lineno"> 1308</span>&#160;   };</div>
<div class="line"><a name="l01309"></a><span class="lineno"> 1309</span>&#160;</div>
<div class="line"><a name="l01310"></a><span class="lineno"> 1310</span>&#160;</div>
<div class="line"><a name="l01311"></a><span class="lineno"> 1311</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01312"></a><span class="lineno"> 1312</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01313"></a><span class="lineno"> 1313</span>&#160;   <span class="comment">// class mutex</span></div>
<div class="line"><a name="l01314"></a><span class="lineno"> 1314</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01316"></a><span class="lineno"> 1316</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01345"></a><span class="lineno"> 1345</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01346"></a><span class="lineno"> 1346</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01347"></a><span class="lineno"> 1347</span>&#160;</div>
<div class="line"><a name="l01348"></a><span class="lineno"> 1348</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01349"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mutex.html"> 1349</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">mutex</a> {</div>
<div class="line"><a name="l01350"></a><span class="lineno"> 1350</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01351"></a><span class="lineno"> 1351</span>&#160;      </div>
<div class="line"><a name="l01353"></a><span class="lineno"> 1353</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l01355"></a><span class="lineno"> 1355</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1mutex.html#a018aed6b83cf182b9990ac90a3254904" title="constructor, specify the name">mutex</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> );</div>
<div class="line"><a name="l01356"></a><span class="lineno"> 1356</span>&#160;      </div>
<div class="line"><a name="l01358"></a><span class="lineno"> 1358</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01360"></a><span class="lineno"> 1360</span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1mutex.html#a58255b4d832c8140f2b45efcc2065733" title="generates an error">~mutex</a>( <span class="keywordtype">void</span> );  </div>
<div class="line"><a name="l01361"></a><span class="lineno"> 1361</span>&#160;      </div>
<div class="line"><a name="l01363"></a><span class="lineno"> 1363</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1mutex.html#aef6201cdf6b86c532629b5888d740303" title="prints a mutex, for debugging only.">print</a>( std::ostream &amp; stream, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01364"></a><span class="lineno"> 1364</span>&#160;</div>
<div class="line"><a name="l01374"></a><span class="lineno"> 1374</span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1mutex.html#a52160d98a50d74a44fc4592a4625c6ed">wait</a>   (<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l01375"></a><span class="lineno"> 1375</span>&#160;      </div>
<div class="line"><a name="l01377"></a><span class="lineno"> 1377</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01385"></a><span class="lineno"> 1385</span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1mutex.html#a9a6cb88e182f977bce35e024449b24cd" title="release the mutex">signal</a> (<span class="keywordtype">void</span>);</div>
<div class="line"><a name="l01386"></a><span class="lineno"> 1386</span>&#160;</div>
<div class="line"><a name="l01387"></a><span class="lineno"> 1387</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01388"></a><span class="lineno"> 1388</span>&#160;      task * owner;             <span class="comment">// current owner of the mutex</span></div>
<div class="line"><a name="l01389"></a><span class="lineno"> 1389</span>&#160;      task * waiters;           <span class="comment">// head of the waiting tasks queue</span></div>
<div class="line"><a name="l01390"></a><span class="lineno"> 1390</span>&#160;<span class="preprocessor">   #if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l01391"></a><span class="lineno"> 1391</span>&#160;<span class="preprocessor"></span>      <span class="keyword">const</span> <span class="keywordtype">char</span> * mutex_name;  <span class="comment">// for logging</span></div>
<div class="line"><a name="l01392"></a><span class="lineno"> 1392</span>&#160;      <a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">mutex</a> *next_mutex;        <span class="comment">// queue of all mutexes, for logging</span></div>
<div class="line"><a name="l01393"></a><span class="lineno"> 1393</span>&#160;      <span class="keywordtype">int</span> wait_count;           <span class="comment">// counts # wait calls;</span></div>
<div class="line"><a name="l01394"></a><span class="lineno"> 1394</span>&#160;<span class="preprocessor">   #endif</span></div>
<div class="line"><a name="l01395"></a><span class="lineno"> 1395</span>&#160;<span class="preprocessor"></span>      <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01396"></a><span class="lineno"> 1396</span>&#160;   };</div>
<div class="line"><a name="l01397"></a><span class="lineno"> 1397</span>&#160;</div>
<div class="line"><a name="l01398"></a><span class="lineno"> 1398</span>&#160;</div>
<div class="line"><a name="l01399"></a><span class="lineno"> 1399</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01400"></a><span class="lineno"> 1400</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01401"></a><span class="lineno"> 1401</span>&#160;   <span class="comment">// class mailbox_base</span></div>
<div class="line"><a name="l01402"></a><span class="lineno"> 1402</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01404"></a><span class="lineno"> 1404</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01405"></a><span class="lineno"> 1405</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01406"></a><span class="lineno"> 1406</span>&#160;</div>
<div class="line"><a name="l01407"></a><span class="lineno"> 1407</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01408"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mailbox__base.html"> 1408</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a> {</div>
<div class="line"><a name="l01409"></a><span class="lineno"> 1409</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01410"></a><span class="lineno"> 1410</span>&#160;      <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *name );</div>
<div class="line"><a name="l01411"></a><span class="lineno"> 1411</span>&#160;</div>
<div class="line"><a name="l01412"></a><span class="lineno"> 1412</span>&#160;      ~<a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a>( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l01413"></a><span class="lineno"> 1413</span>&#160;         mkt_fatal (#UNIQUE_ERROR); <span class="comment">// mailbox destructor called</span></div>
<div class="line"><a name="l01414"></a><span class="lineno"> 1414</span>&#160;      }</div>
<div class="line"><a name="l01415"></a><span class="lineno"> 1415</span>&#160;</div>
<div class="line"><a name="l01416"></a><span class="lineno"> 1416</span>&#160;      <span class="keywordtype">void</span> print( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01417"></a><span class="lineno"> 1417</span>&#160;</div>
<div class="line"><a name="l01418"></a><span class="lineno"> 1418</span>&#160;      task * client;</div>
<div class="line"><a name="l01419"></a><span class="lineno"> 1419</span>&#160;<span class="preprocessor">   #if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l01420"></a><span class="lineno"> 1420</span>&#160;<span class="preprocessor"></span>      <span class="keyword">const</span> <span class="keywordtype">char</span> * mailbox_name;</div>
<div class="line"><a name="l01421"></a><span class="lineno"> 1421</span>&#160;      <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> writes;</div>
<div class="line"><a name="l01422"></a><span class="lineno"> 1422</span>&#160;      <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a> *next_mailbox;</div>
<div class="line"><a name="l01423"></a><span class="lineno"> 1423</span>&#160;<span class="preprocessor">   #endif</span></div>
<div class="line"><a name="l01424"></a><span class="lineno"> 1424</span>&#160;<span class="preprocessor"></span>   </div>
<div class="line"><a name="l01425"></a><span class="lineno"> 1425</span>&#160;   };</div>
<div class="line"><a name="l01426"></a><span class="lineno"> 1426</span>&#160;</div>
<div class="line"><a name="l01427"></a><span class="lineno"> 1427</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01428"></a><span class="lineno"> 1428</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01429"></a><span class="lineno"> 1429</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01430"></a><span class="lineno"> 1430</span>&#160;   <span class="comment">// class mailbox</span></div>
<div class="line"><a name="l01431"></a><span class="lineno"> 1431</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01433"></a><span class="lineno"> 1433</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01459"></a><span class="lineno"> 1459</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01460"></a><span class="lineno"> 1460</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01461"></a><span class="lineno"> 1461</span>&#160;</div>
<div class="line"><a name="l01462"></a><span class="lineno"> 1462</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01463"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mailbox.html"> 1463</a></span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1mailbox.html" title="synchronous handling over of a data item">mailbox</a> : <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a> {</div>
<div class="line"><a name="l01464"></a><span class="lineno"> 1464</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01465"></a><span class="lineno"> 1465</span>&#160;      </div>
<div class="line"><a name="l01467"></a><span class="lineno"> 1467</span>&#160;        <span class="comment">//</span></div>
<div class="line"><a name="l01469"></a><span class="lineno"> 1469</span>&#160;<span class="comment"></span>        <span class="comment">// The name is used for debugging and statistics.</span></div>
<div class="line"><a name="l01473"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mailbox.html#aaee470ef9fc6627e848e45ca353415ff"> 1473</a></span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1mailbox.html#aaee470ef9fc6627e848e45ca353415ff" title="construtor, specify mutex name">mailbox</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span>  ): <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">mailbox_base</a>( name ){}</div>
<div class="line"><a name="l01474"></a><span class="lineno"> 1474</span>&#160;</div>
<div class="line"><a name="l01476"></a><span class="lineno"> 1476</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01484"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mailbox.html#ad140965320e8b42ca16a5d288858f70d"> 1484</a></span>&#160;<span class="comment"></span>      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1mailbox.html#ad140965320e8b42ca16a5d288858f70d" title="write an item into the mailbox">write</a>( <span class="keyword">const</span> T item ) {</div>
<div class="line"><a name="l01485"></a><span class="lineno"> 1485</span>&#160;         RTOS_STATISTICS( writes++; )</div>
<div class="line"><a name="l01486"></a><span class="lineno"> 1486</span>&#160;         data = item;</div>
<div class="line"><a name="l01487"></a><span class="lineno"> 1487</span>&#160;         <span class="keywordflow">if</span> ( client != NULL ) {</div>
<div class="line"><a name="l01488"></a><span class="lineno"> 1488</span>&#160;            <span class="comment">// someone is waiting to read, unblock it</span></div>
<div class="line"><a name="l01489"></a><span class="lineno"> 1489</span>&#160;            client-&gt;unblock();</div>
<div class="line"><a name="l01490"></a><span class="lineno"> 1490</span>&#160;            } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01491"></a><span class="lineno"> 1491</span>&#160;                <span class="comment">// block until the reader gets the data</span></div>
<div class="line"><a name="l01492"></a><span class="lineno"> 1492</span>&#160;                client = <a class="code" href="class_r_t_o_s.html#a7e455e2e010e6af8f9f41cbeacfe6bd0" title="returns (a pointer to) the currently executing task">RTOS::current_task</a>();</div>
<div class="line"><a name="l01493"></a><span class="lineno"> 1493</span>&#160;             client-&gt;block();</div>
<div class="line"><a name="l01494"></a><span class="lineno"> 1494</span>&#160;            }</div>
<div class="line"><a name="l01495"></a><span class="lineno"> 1495</span>&#160;      }</div>
<div class="line"><a name="l01496"></a><span class="lineno"> 1496</span>&#160;      </div>
<div class="line"><a name="l01498"></a><span class="lineno"> 1498</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01506"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1mailbox.html#af2bc862b64929b5ec34afa4dec0ed720"> 1506</a></span>&#160;<span class="comment"></span>      T <a class="code" href="class_r_t_o_s_1_1mailbox.html#af2bc862b64929b5ec34afa4dec0ed720" title="read a value from the mailbox">read</a> (<span class="keywordtype">void</span>) {</div>
<div class="line"><a name="l01507"></a><span class="lineno"> 1507</span>&#160;         <span class="keywordflow">if</span> ( client == NULL ) {</div>
<div class="line"><a name="l01508"></a><span class="lineno"> 1508</span>&#160;            <span class="comment">// no writer yet, so wait for a writer</span></div>
<div class="line"><a name="l01509"></a><span class="lineno"> 1509</span>&#160;            client = <a class="code" href="class_r_t_o_s.html#a7e455e2e010e6af8f9f41cbeacfe6bd0" title="returns (a pointer to) the currently executing task">RTOS::current_task</a>();</div>
<div class="line"><a name="l01510"></a><span class="lineno"> 1510</span>&#160;            client-&gt;block();</div>
<div class="line"><a name="l01511"></a><span class="lineno"> 1511</span>&#160;         }</div>
<div class="line"><a name="l01512"></a><span class="lineno"> 1512</span>&#160;         <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01513"></a><span class="lineno"> 1513</span>&#160;            <span class="comment">// unblock the writer</span></div>
<div class="line"><a name="l01514"></a><span class="lineno"> 1514</span>&#160;            client-&gt;unblock();</div>
<div class="line"><a name="l01515"></a><span class="lineno"> 1515</span>&#160;              client = NULL;</div>
<div class="line"><a name="l01516"></a><span class="lineno"> 1516</span>&#160;         }</div>
<div class="line"><a name="l01517"></a><span class="lineno"> 1517</span>&#160;           <span class="keywordflow">return</span> data;</div>
<div class="line"><a name="l01518"></a><span class="lineno"> 1518</span>&#160;      }</div>
<div class="line"><a name="l01519"></a><span class="lineno"> 1519</span>&#160;</div>
<div class="line"><a name="l01520"></a><span class="lineno"> 1520</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01521"></a><span class="lineno"> 1521</span>&#160;      T data;</div>
<div class="line"><a name="l01522"></a><span class="lineno"> 1522</span>&#160;   };</div>
<div class="line"><a name="l01523"></a><span class="lineno"> 1523</span>&#160;</div>
<div class="line"><a name="l01524"></a><span class="lineno"> 1524</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01525"></a><span class="lineno"> 1525</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01526"></a><span class="lineno"> 1526</span>&#160;   <span class="comment">// class channel_base</span></div>
<div class="line"><a name="l01527"></a><span class="lineno"> 1527</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01529"></a><span class="lineno"> 1529</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01530"></a><span class="lineno"> 1530</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01531"></a><span class="lineno"> 1531</span>&#160;</div>
<div class="line"><a name="l01532"></a><span class="lineno"> 1532</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01533"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel__base.html"> 1533</a></span>&#160;   <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1waitable.html" title="abstract thing that a task can wait for">waitable</a>{</div>
<div class="line"><a name="l01534"></a><span class="lineno"> 1534</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01535"></a><span class="lineno"> 1535</span>&#160;      ~<a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a>( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l01536"></a><span class="lineno"> 1536</span>&#160;         mkt_fatal (#UNIQUE_ERROR); <span class="comment">// channel destructor called</span></div>
<div class="line"><a name="l01537"></a><span class="lineno"> 1537</span>&#160;      }</div>
<div class="line"><a name="l01538"></a><span class="lineno"> 1538</span>&#160;</div>
<div class="line"><a name="l01539"></a><span class="lineno"> 1539</span>&#160;      <span class="keywordtype">void</span> print( std::ostream &amp; s, <span class="keywordtype">bool</span> header = <span class="keyword">true</span> ) <span class="keyword">const</span>;</div>
<div class="line"><a name="l01540"></a><span class="lineno"> 1540</span>&#160;</div>
<div class="line"><a name="l01541"></a><span class="lineno"> 1541</span>&#160;   <span class="keyword">protected</span>:</div>
<div class="line"><a name="l01542"></a><span class="lineno"> 1542</span>&#160;      <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a>( task * t, <span class="keyword">const</span> <span class="keywordtype">char</span> *name );</div>
<div class="line"><a name="l01543"></a><span class="lineno"> 1543</span>&#160;</div>
<div class="line"><a name="l01544"></a><span class="lineno"> 1544</span>&#160;<span class="preprocessor">   #if RTOS_STATISTICS_ENABLED</span></div>
<div class="line"><a name="l01545"></a><span class="lineno"> 1545</span>&#160;<span class="preprocessor"></span>      <span class="keyword">const</span> <span class="keywordtype">char</span> *channel_name;</div>
<div class="line"><a name="l01546"></a><span class="lineno"> 1546</span>&#160;      <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a> *next_channel;</div>
<div class="line"><a name="l01547"></a><span class="lineno"> 1547</span>&#160;      <span class="keywordtype">int</span> writes;</div>
<div class="line"><a name="l01548"></a><span class="lineno"> 1548</span>&#160;      <span class="keywordtype">int</span> ignores;</div>
<div class="line"><a name="l01549"></a><span class="lineno"> 1549</span>&#160;<span class="preprocessor">   #endif</span></div>
<div class="line"><a name="l01550"></a><span class="lineno"> 1550</span>&#160;<span class="preprocessor"></span>      <span class="keywordtype">int</span> qSize;</div>
<div class="line"><a name="l01551"></a><span class="lineno"> 1551</span>&#160;      <span class="keywordtype">int</span> head;</div>
<div class="line"><a name="l01552"></a><span class="lineno"> 1552</span>&#160;      <span class="keywordtype">int</span> tail;</div>
<div class="line"><a name="l01553"></a><span class="lineno"> 1553</span>&#160;      <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>;</div>
<div class="line"><a name="l01554"></a><span class="lineno"> 1554</span>&#160;   };</div>
<div class="line"><a name="l01555"></a><span class="lineno"> 1555</span>&#160;</div>
<div class="line"><a name="l01556"></a><span class="lineno"> 1556</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01557"></a><span class="lineno"> 1557</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01558"></a><span class="lineno"> 1558</span>&#160;   <span class="comment">// class channel</span></div>
<div class="line"><a name="l01559"></a><span class="lineno"> 1559</span>&#160;   <span class="comment">//</span></div>
<div class="line"><a name="l01561"></a><span class="lineno"> 1561</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01615"></a><span class="lineno"> 1615</span>&#160;<span class="comment"></span>   <span class="comment">//</span></div>
<div class="line"><a name="l01616"></a><span class="lineno"> 1616</span>&#160;   <span class="comment">//************************************************************************</span></div>
<div class="line"><a name="l01617"></a><span class="lineno"> 1617</span>&#160;</div>
<div class="line"><a name="l01618"></a><span class="lineno"> 1618</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l01619"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel.html"> 1619</a></span>&#160;   <span class="keyword">template</span> &lt;<span class="keyword">class</span> T, const <span class="keywordtype">int</span> SIZE&gt; <span class="keyword">class </span><a class="code" href="class_r_t_o_s_1_1channel.html" title="waitable data queue">channel</a> : <span class="keyword">public</span> <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a> {</div>
<div class="line"><a name="l01620"></a><span class="lineno"> 1620</span>&#160;   <span class="keyword">public</span>:</div>
<div class="line"><a name="l01621"></a><span class="lineno"> 1621</span>&#160;</div>
<div class="line"><a name="l01623"></a><span class="lineno"> 1623</span>&#160;      <span class="comment">//</span></div>
<div class="line"><a name="l01626"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel.html#a5580e7cd248a64985c8866c528cfebe6"> 1626</a></span>&#160;<span class="comment"></span>      <a class="code" href="class_r_t_o_s_1_1channel.html#a5580e7cd248a64985c8866c528cfebe6" title="constructor, specify stored type, number of entries, and name">channel</a>( task * t, <span class="keyword">const</span> <span class="keywordtype">char</span> *name = <span class="stringliteral">&quot;&quot;</span> ): <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">channel_base</a>( t, name ){}</div>
<div class="line"><a name="l01627"></a><span class="lineno"> 1627</span>&#160;</div>
<div class="line"><a name="l01629"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel.html#a09e4d10e0336283eb9ae402df0a25dbc"> 1629</a></span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1channel.html#a09e4d10e0336283eb9ae402df0a25dbc" title="write an item to the queue">write</a>( T item ) {</div>
<div class="line"><a name="l01630"></a><span class="lineno"> 1630</span>&#160;         <span class="keywordflow">if</span>( qSize &lt; SIZE ) {</div>
<div class="line"><a name="l01631"></a><span class="lineno"> 1631</span>&#160;            RTOS_STATISTICS( writes++; )</div>
<div class="line"><a name="l01632"></a><span class="lineno"> 1632</span>&#160;            queue[head] = item;</div>
<div class="line"><a name="l01633"></a><span class="lineno"> 1633</span>&#160;            <span class="keywordflow">if</span>( ++head == SIZE ) {</div>
<div class="line"><a name="l01634"></a><span class="lineno"> 1634</span>&#160;               head = 0;</div>
<div class="line"><a name="l01635"></a><span class="lineno"> 1635</span>&#160;            }</div>
<div class="line"><a name="l01636"></a><span class="lineno"> 1636</span>&#160;            qSize += 1;</div>
<div class="line"><a name="l01637"></a><span class="lineno"> 1637</span>&#160;            <a class="code" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e" title="set the waitable">waitable::set</a>();</div>
<div class="line"><a name="l01638"></a><span class="lineno"> 1638</span>&#160;         } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01639"></a><span class="lineno"> 1639</span>&#160;            RTOS_STATISTICS( ignores++; )</div>
<div class="line"><a name="l01640"></a><span class="lineno"> 1640</span>&#160;         }</div>
<div class="line"><a name="l01641"></a><span class="lineno"> 1641</span>&#160;      }</div>
<div class="line"><a name="l01642"></a><span class="lineno"> 1642</span>&#160;</div>
<div class="line"><a name="l01644"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel.html#a66da852f3e9ef72066e5f582f4c2f218"> 1644</a></span>&#160;      T <a class="code" href="class_r_t_o_s_1_1channel.html#a66da852f3e9ef72066e5f582f4c2f218" title="read an item from the queue">read</a>( <span class="keywordtype">void</span> ) {</div>
<div class="line"><a name="l01645"></a><span class="lineno"> 1645</span>&#160;         <span class="keywordflow">if</span>( qSize == 0 ) {</div>
<div class="line"><a name="l01646"></a><span class="lineno"> 1646</span>&#160;            t-&gt;<a class="code" href="class_r_t_o_s_1_1task.html#a6fc603d0f1c8a94813586d3dfd123fcc" title="wait for all waitables created for this task">wait</a>( *<span class="keyword">this</span> );</div>
<div class="line"><a name="l01647"></a><span class="lineno"> 1647</span>&#160;         }</div>
<div class="line"><a name="l01648"></a><span class="lineno"> 1648</span>&#160;</div>
<div class="line"><a name="l01649"></a><span class="lineno"> 1649</span>&#160;         <span class="keywordflow">if</span>( qSize == 0 ) {</div>
<div class="line"><a name="l01650"></a><span class="lineno"> 1650</span>&#160;            mkt_fatal (#UNIQUE_ERROR); <span class="comment">// channel should not be empty now</span></div>
<div class="line"><a name="l01651"></a><span class="lineno"> 1651</span>&#160;         }</div>
<div class="line"><a name="l01652"></a><span class="lineno"> 1652</span>&#160;         T buf = queue[ tail ];</div>
<div class="line"><a name="l01653"></a><span class="lineno"> 1653</span>&#160;         <span class="keywordflow">if</span>( ++tail == SIZE ) {</div>
<div class="line"><a name="l01654"></a><span class="lineno"> 1654</span>&#160;            tail = 0;</div>
<div class="line"><a name="l01655"></a><span class="lineno"> 1655</span>&#160;         }</div>
<div class="line"><a name="l01656"></a><span class="lineno"> 1656</span>&#160;         qSize -= 1;</div>
<div class="line"><a name="l01657"></a><span class="lineno"> 1657</span>&#160;         <span class="keywordflow">if</span>( qSize &gt; 0 ) {</div>
<div class="line"><a name="l01658"></a><span class="lineno"> 1658</span>&#160;            <a class="code" href="class_r_t_o_s_1_1waitable.html#a3a72bdf94092471e82ba2d04cdc4a58e" title="set the waitable">waitable::set</a>();</div>
<div class="line"><a name="l01659"></a><span class="lineno"> 1659</span>&#160;         } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l01660"></a><span class="lineno"> 1660</span>&#160;            <a class="code" href="class_r_t_o_s_1_1channel.html#afd8cd81a91225ed144fc1ca20f3cd8f6" title="clear the waitable">waitable::clear</a>();</div>
<div class="line"><a name="l01661"></a><span class="lineno"> 1661</span>&#160;         }</div>
<div class="line"><a name="l01662"></a><span class="lineno"> 1662</span>&#160;         <span class="keywordflow">return</span> buf;</div>
<div class="line"><a name="l01663"></a><span class="lineno"> 1663</span>&#160;      }</div>
<div class="line"><a name="l01664"></a><span class="lineno"> 1664</span>&#160;</div>
<div class="line"><a name="l01665"></a><span class="lineno"><a class="code" href="class_r_t_o_s_1_1channel.html#afd8cd81a91225ed144fc1ca20f3cd8f6"> 1665</a></span>&#160;      <span class="keywordtype">void</span> <a class="code" href="class_r_t_o_s_1_1channel.html#afd8cd81a91225ed144fc1ca20f3cd8f6" title="clear the waitable">clear</a> (<span class="keywordtype">void</span>) {</div>
<div class="line"><a name="l01666"></a><span class="lineno"> 1666</span>&#160;         qSize = 0;</div>
<div class="line"><a name="l01667"></a><span class="lineno"> 1667</span>&#160;         head = tail = 0;</div>
<div class="line"><a name="l01668"></a><span class="lineno"> 1668</span>&#160;         <a class="code" href="class_r_t_o_s_1_1channel.html#afd8cd81a91225ed144fc1ca20f3cd8f6" title="clear the waitable">waitable::clear</a>();</div>
<div class="line"><a name="l01669"></a><span class="lineno"> 1669</span>&#160;      }</div>
<div class="line"><a name="l01670"></a><span class="lineno"> 1670</span>&#160;   <span class="keyword">private</span>:</div>
<div class="line"><a name="l01671"></a><span class="lineno"> 1671</span>&#160;      T queue[ SIZE] ;</div>
<div class="line"><a name="l01672"></a><span class="lineno"> 1672</span>&#160;   };</div>
<div class="line"><a name="l01673"></a><span class="lineno"> 1673</span>&#160;</div>
<div class="line"><a name="l01674"></a><span class="lineno"> 1674</span>&#160;};</div>
<div class="line"><a name="l01675"></a><span class="lineno"> 1675</span>&#160;</div>
<div class="line"><a name="l01676"></a><span class="lineno"> 1676</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1task.html" title="an independent thread of execution">RTOS::task</a> &amp; t );</div>
<div class="line"><a name="l01677"></a><span class="lineno"> 1677</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1flag.html" title="basic synchronisation mechanism.">RTOS::flag</a> &amp; f );</div>
<div class="line"><a name="l01678"></a><span class="lineno"> 1678</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1event.html" title="set of things that can happen, or a thing that has happened">RTOS::event</a> &amp; e );</div>
<div class="line"><a name="l01679"></a><span class="lineno"> 1679</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1timer.html" title="one-short timer">RTOS::timer</a> &amp; t );</div>
<div class="line"><a name="l01680"></a><span class="lineno"> 1680</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1clock.html" title="free-running clock, ticks at a fixed frequency">RTOS::clock</a> &amp; c );</div>
<div class="line"><a name="l01681"></a><span class="lineno"> 1681</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1channel__base.html" title="RTOS private implementation class.">RTOS::channel_base</a> &amp; c );</div>
<div class="line"><a name="l01682"></a><span class="lineno"> 1682</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1mutex.html" title="mutual execlusion semaphore">RTOS::mutex</a> &amp; m );</div>
<div class="line"><a name="l01683"></a><span class="lineno"> 1683</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1mailbox__base.html" title="RTOS private implementation class.">RTOS::mailbox_base</a> &amp; m );</div>
<div class="line"><a name="l01684"></a><span class="lineno"> 1684</span>&#160;std::ostream &amp; operator&lt;&lt; ( std::ostream &amp; s, <span class="keyword">const</span> <a class="code" href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class.">RTOS::pool_base</a> &amp; p );</div>
<div class="line"><a name="l01685"></a><span class="lineno"> 1685</span>&#160;</div>
<div class="line"><a name="l01686"></a><span class="lineno"> 1686</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 27 2012 11:07:14 for TagM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
